#include <iostream>
#include "Ghost.h"
#include "ShellProxy.h"

Ghost::Ghost(SimulatorRegister * registration)
{
    this->registration = registration;
    shellProxy = 0;
}

Ghost::~Ghost()
{
    if(shellProxy)
        delete shellProxy;
}

void Ghost::bind(SimulatorRegister * registration)
{
//    if(shellProxy != '\0')
//        shellProxy->unregister();
    
    this->registration = registration;
    
    shellProxy = registration->registerGhost(this);
}

bool Ghost::isBound()
{
    return (registration != 0);
}

// give info to others
//const Flags & getFlags() const;
const Position & Ghost::getPosition() const
{
    return shellProxy->getPosition();
}

bool Ghost::isActive() const
{
    return shellProxy->isActive();
}

//protected:  

// what we can do (it's a bureaucracy)
bool Ghost::requestMove(Direction & dir)
{
    return shellProxy->requestMove(dir);
}

bool Ghost::requestPosition(Position & pos)
{
    return shellProxy->requestPosition(pos);
}

//bool Ghost::requestFlag( vb hiddenFlag)
//{
//    return shell->requestFlag(dir);
//}

// request information about others
//void Ghost::getInfoAbout(Ghost * other)
//{
//}

//const Ghost * Ghost::getGhostAt(Position & position)
//{
//    //return NULL on objects out of position
//    // THROW()
//    return shellProxy->getGhostAt(position);
//}

